package com.itheima.partition;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

//k1:行的偏移量
public class CaiPiaoMapperTask extends Mapper<LongWritable, Text, IntWritable,Text> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        //获取一行数据
        String line = value.toString();

        if(line!=null & !"".equals(line)){
            //2、对数据进行切割操作
            String code = line.split("\t")[5];
            int codeInt = Integer.parseInt(code);

            context.write(new IntWritable(codeInt),value);
        }

    }
}
